package cn.tedu.csmall.stock.webapi.mapper;

import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Update;
import org.springframework.stereotype.Repository;

@Repository
public interface StockMapper {

    //减少指定商品库存数的方法
    @Update("UPDATE stock_tbl SET count = count-#{reduceCount} WHERE commodity_code = #{commodityCode} AND count>=#{reduceCount}")
    int updateStockCount(@Param("reduceCount") Integer reduceCount,@Param("commodityCode") String commodityCode);

//    @Update("UPDATE stock_tbl set count = count+1 WHERE commodity_code = #{commodityCode}")
//    int updateByCommodityCodeAdd(String commodityCode);

}
